#!/user/bin/python
# -*- coding: utf-8 -*-
'''
 @Time    : 2018/5/9 22:05
 @File    : context_manager.py
 @desc    :
'''
from commonSpiders.utils.singleton import singleton

@singleton
class ContextManager(dict):

    def set_context(self, key, value):
        if not key or not value:
            return
        self.setdefault(key, value)

    def get_context(self, key, default={}):
        if not key:
            return default
        return self.get(key, default)
